{{useCss "/app-pages/css/pay.scss"}}
<div class="_pay">
    <div class="order {{#if $Cache.pay.is_change_address}}focus{{/if}}">
        <!-- 收货地址 -->
        <div class="pay_title">订单支付</div>
        {{#if $Cache.pay.pay_ach.info.user_address}}
        <div class="connect" event-click="{{'$Event.pay.change_addr'}}">
            <div class="icon-right-open-big"></div>
            <div class="people">
                <div class="name">联系人：{{$Cache.pay.pay_ach.info.user_address.name}}</div>
                <div class="phone">{{$Cache.pay.pay_ach.info.user_address.mobilenumber}}</div>
            </div>
            <div class="address">
                {{$Cache.pay.pay_ach.info.user_address.province+', '+$Cache.pay.pay_ach.info.user_address.town+', '+$Cache.pay.pay_ach.info.user_address.county+', '+$Cache.pay.pay_ach.info.user_address.detail}}
            </div>
        </div>
        {{#else}}
        <div class="connect" event-click="{{'$Event.pay.change_addr'}}">
            <div class="address">请选择收货地址</div>
        </div>
        {{/if}}
        
        <!-- 支付方式 -->
        <div class="pay_title">支付方式</div>
        <div class="pay_box">
            {{#if $Cache.pay.pay_ach.info.state==config.ACH_STATE.未确认}}
            {{#if !$Top._is_weixin}}
            <mbPayMethod
                value="alipay.wap.auth.authAndExecute"
                text="支付宝"
                intro="使用支付宝网页支付"
                disabled="{{!(bus_info.info.alipay.seller_email&&bus_info.info.alipay.key&&bus_info.info.alipay.partner)}}"
            ></mbPayMethod>
            {{/if}}
            {{#if !$Cache.pay.pay_ach.info.is_only_online_pay}}
            <!-- <mbPayMethod
                value="payment_in_cash"
                text="货到付款"
                intro="用于大金额订单"
            ></mbPayMethod> -->
            {{/if}}
            {{#if $Top._is_weixin}}
            <mbPayMethod
                value="weixin_pay"
                text="微信支付"
                intro="在微信中直接使用微信进行支付"
            ></mbPayMethod>
            {{/if}}
            {{#else}}
            <br/>
            <p>
                {{#if $Cache.pay.pay_ach.info.pay_method=="alipay.wap.auth.authAndExecute"}}
                使用支付宝的快捷支付(不可更改)
                {{/if}}
                {{#if $Cache.pay.pay_ach.info.pay_method=="payment_in_cash"}}
                货到付款(不可更改)
                {{/if}}
                {{#if $Cache.pay.pay_ach.info.pay_method=="weixin_pay"}}
                微信支付(不可更改)
                {{/if}}
            </p>
            {{/if}}
        </div>
        
        <!-- 使用优惠券 -->
        <div class="pay_title">使用优惠券</div>
        <div class="tickets">
        {{#if $Cache.pay.pay_ach.ticket_id}}
            <div class="ticket focus">
            本订单已使用优惠券（不可更改）
            </div>
        {{#else}}
            {{#if $Cache.pay.pay_ach.info.state==config.ACH_STATE.未确认}}
                {{#if $Cache.pay.user_tickets.length}}
                {{#each $Cache.pay.user_tickets}}
                <div class="ticket {{($Top.$Cache.pay_ach.ticket_id==_id)&&'checked'}}" event-click="{{'$Top.$Event.pay.choose_ticket'}}">
                    <div class="name">{{ticket_factory.info.name}}</div>
                    <div class="type">满{{ticket_factory.info.config.full_cash}}减{{ticket_factory.info.config.cut_cash}}</div>
                </div>
                {{/each}}
                <div class="ticket focus" event-click="{{'$Event.pay.using_checked_ticket'}}">点此确定使用优惠券（不可更改）</div>
                {{#else}}
                <div class="ticket">目前没有可用的优惠券</div>
                {{/if}}
            {{#else}}
            <div class="ticket">本订单没有使用优惠券</div>
            {{/if}}
        {{/if}}
        </div>
    </div>
    <div class="address">
        <div>
            <button class="btn" event-click="{{'$Event.pay.change_addr'}}">返回</button>
        </div>
        {{#each user.address_detail}}
        <div class="addr {{#if $Top.$Cache.pay.pay_ach.info.user_address._id==_id}}focus{{/if}}" event-click="{{'$Top.$Event.pay.change_user_address'}}">{{name}}，{{mobilenumber}} {{phonenumber&&("/"+phonenumber)}}，{{province}}{{town}}{{county}}，{{detail}}</div>
        {{/each}}

        <button class="btn" event-click="{{'$Event.pay.isadd_addr'}}">{{#if $Cache.pay.isadd_addr}}取消{{#else}}增加地址{{/if}}</button>
        <div class="add_info {{#if $Cache.pay.isadd_addr}}focus{{/if}}">
            <select name="province" event-change="{{'$Event.province'}}">
                <option class="first" value="0">请选择省</option>
                {{#each city_list}}
                <option rel="{{region_id}}" value="{{region_name}}">
                    {{region_name}}
                </option>
                {{/each}}
            </select>

            <select name="city" disabled event-change="{{'$Event.city'}}">
                <option class="first" value="0">请选择市</option>
            </select>

            <select name="area" disabled>
                <option class="first" value="0">请选择地区</option>
            </select>
            <L:input name="detailed_addre" placeholder="详细地址"></L:input>
            <L:input name="name" placeholder="姓名"></L:input>
            <L:input name="mobile_num" placeholder="手机号"></L:input>
            <button class="btn" event-click="{{'$Event.pay.add_user_address'}}">确认地址</button>
        </div>
    </div>
</div>


<div class="blockbottom"></div>
<div class="topay {{#if $Cache.pay.pay_ach.info.state==config.ACH_STATE.ol未付款||$Cache.pay.pay_ach.info.state==config.ACH_STATE.未发货}}focus{{/if}}">
	应付金额:<span style="color:red">￥{{#Fixed $Cache.pay.pay_ach.finally_cash}}</span>
    {{#> "user_ach_controller","$Cache.pay.pay_ach"}}
</div>
<xmp type="tag" name="mbPayMethod">
    <button class="pay-type-wrap {{$Top.$Cache.pay.pay_ach.info.pay_method=='${value}'&&'checked'}}" event-click="{{'$Top.$Event.pay.change_pay_method'}}" ${__all_attrs__} >
        <div class="pay-type pay3" name="pay3" event-click="{{'$Event.pay.changepay'}}">
        ${text}
        </div>
    </button>
</xmp>